﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace T12OOP
{
    class Contact
    {
        private string name;
        private string homePhone;
        private string mobilePhone;
        private string busiPhone;
        private string fax;
        public Contact(string name)
            {
            this.name=name;
            }

        //只读属性
        public string Name
        {
            get { return name; }
        }
        //索引方式
        public string this[string type]
        {
            get
            {
                switch (type)
                {
                    case "mobile": return mobilePhone;
                    case "home": return homePhone;
                    case "business": return busiPhone;
                    case "fax": return fax;
                    default: return "none";
                }
            }
            set
            {
                switch (type)
                {
                    case "mobile": mobilePhone = value; break;
                    case "home": homePhone = value; break;
                    case "business": busiPhone = value; break;
                    case "fax": fax = value; break;

                }
            }
        }
        public override string ToString()
        {
            return string.Format("名字是：{0}，移动电话是：{1}，家庭电话是：{2}，工作电话是：{3}，传真电话是：{4}", name, mobilePhone, homePhone, busiPhone, fax);
        }
    }
}

